package com.woniuxy.ams.service.impl;

import com.woniuxy.ams.dao.CompanyTemplateDao;
import com.woniuxy.ams.entity.CompanyTemplate;
import com.woniuxy.ams.service.ICompanyTemplateService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公司考核模板Service实现
 */
@Service
public class CompanyTemplateServiceImpl implements ICompanyTemplateService {

    /**
     * 注入dao
     */
    @Resource
    CompanyTemplateDao companyTemplateDao;


    /**
     * 新增考核模板
     * @param template
     * @return int
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public int addTemplate(CompanyTemplate template) {
        int row = companyTemplateDao.addTemplate(template);
        return row;

    }

    /**
     * 查询所有考核模板
     * @return List<CompanyTemplate>
     */
    @Override
    public List<CompanyTemplate> findAllTemplate() {
        return companyTemplateDao.findAllTemplate();
    }

    /**
     * 更改公司考核模板
     * @param template
     * @return int
     */
    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public int updateTemplate(CompanyTemplate template) {
        return companyTemplateDao.updateTemplate(template);
    }
}
